﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Pro_ContatReport.aspx.cs" Inherits="ArtLand.OA.Project.Project.Pro_ContatReport" %>


<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link href="../css/admin.css" rel="stylesheet" />
    <script src="../js/WebCommon.js"></script>
    <style>
        .mygrid-row-summary.x-grid3-row {
            background-color: #efefef !important;
            background-image: none !important;
            border-color: #fff #ededed #ededed !important;
            visibility: hidden;
        }

            .mygrid-row-summary.x-grid3-row .x-grid3-td-numberer, .mygrid-row-summary.x-grid3-row .x-grid3-td-checker {
                background-image: none !important;
            }

                .mygrid-row-summary.x-grid3-row .x-grid3-td-numberer .x-grid3-col-numberer, .mygrid-row-summary.x-grid3-row .x-grid3-td-checker .x-grid3-col-checker {
                    display: none;
                }

            .mygrid-row-summary.x-grid3-row td {
                font-size: 14px;
                line-height: 16px;
                font-weight: bold;
                color: blue;
            }
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <ext:PageManager ID="PageManager1" runat="server" AutoSizePanelID="pan1" />
        <ext:Panel ShowBorder="false" ShowHeader="false" runat="server" ID="pan1" Layout="Fit">
            <Items>
                <ext:Grid ID="Grid1" Title="项目合同管理" ShowHeader="false" ShowBorder="false" runat="server" EnableCheckBoxSelect="true" DataKeyNames="ID,IsFinsh"
                    OnRowDataBound="Grid1_RowDataBound" EnableColumnLines="true">
                    <Toolbars>
                        <ext:Toolbar ID="Toolbar1" runat="server">
                            <Items>
                                <ext:ToolbarText ID="ToolbarText2" runat="server" Enabled="false" Text=""></ext:ToolbarText>
                            </Items>
                        </ext:Toolbar>
                    </Toolbars>
                    <Columns>
                        <ext:BoundField Width="100px" DataField="CONNUB" DataFormatString="{0}" HeaderText="合同编号" />
                        <ext:BoundField Width="120px" DataField="AddTime" DataFormatString="{0:yyyy-MM-dd}" HeaderText="合同日期" TextAlign="Center" />
                        <ext:BoundField Width="120px" DataField="CONDES" DataFormatString="{0}" HeaderText="合同描述" TextAlign="Center" />
                        <ext:BoundField Width="120px" DataField="PRJNUB" DataFormatString="{0}" HeaderText="项目编号" TextAlign="Center" />
                        <ext:BoundField Width="120px" ColumnID="major" DataField="CUTNUB" DataFormatString="{0}" HeaderText="客户编号" TextAlign="Center" />
                        <ext:BoundField Width="160px" ColumnID="donate" DataField="AMOUNT" DataFormatString="{0}" HeaderText="合同总金额" TextAlign="Center" />
                        <ext:BoundField Width="160px" ColumnID="fee" DataField="ID" DataFormatString="{0}" HeaderText="未收金额" TextAlign="Center" />

                    </Columns>
                </ext:Grid>
            </Items>
        </ext:Panel>

        <ext:Window ID="Window1" Title="编辑" Popup="false" EnableIFrame="true" runat="server"
            CloseAction="HidePostBack" EnableConfirmOnClose="true" IFrameUrl="about:blank" Target="Top" IsModal="True" Width="520px" Height="490px">
        </ext:Window>
        <ext:Window ID="Window2" Title="编辑" Popup="false" EnableIFrame="true" runat="server"
            CloseAction="HidePostBack" EnableConfirmOnClose="true" IFrameUrl="about:blank" Target="Top" IsModal="True" Width="605px" Height="350px">
        </ext:Window>
        <ext:Label ID="labResult" EncodeText="false" runat="server">
        </ext:Label>

    </form>
    <script src="../js/extgridbug.js"></script>
    <script>

        var gridClientID = '<%= Grid1.ClientID %>';
        var gridSummaryID = '<%=t %>';
       
        function calcGridSummary(grid) {
            var donateTotal = 0, store = grid.getStore(), view = grid.getView(), storeCount = store.getCount();

            // 防止重复添加了合计行
            if (Ext.get(view.getRow(storeCount - 1)).hasClass('mygrid-row-summary')) {
                return;
            }
           // alert(gridSummaryID);
            // 从隐藏字段获取全部数据的汇总
            var summaryJSON = JSON.parse(gridSummaryID);


            store.add(new Ext.data.Record({
                'major': '金额汇总：',
                'donate': summaryJSON['donateTotal'].toFixed(2),
                'fee': summaryJSON['feeTotal'].toFixed(2)
            }));


            // 为合计行添加自定义样式（隐藏序号列、复选框列，取消 hover 和 selected 效果）
            var summaryNode = Ext.get(view.getRow(storeCount)).addClass('mygrid-row-summary');

            // 找到合计行的外部容器节点
            var viewportNode = summaryNode.parent('.x-grid3-viewport');
            // 删除容器节点下直接子节点为 mygrid-row-summary 的节点
            viewportNode.select('> .mygrid-row-summary').remove();

            // 创建合计行的副本
            var cloneSummaryNode = summaryNode.dom.cloneNode(true);
            // 修改合计行的副本的样式，绝对定位，距离底部0px，显示副本（默认是占位隐藏 visibility: hidden;）
            Ext.get(cloneSummaryNode).setStyle({
                position: 'absolute',
                bottom: 0,
                visibility: 'visible'
            });

            // 向容器节点添加合计行的副本
            viewportNode.appendChild(cloneSummaryNode);

        }

        // 页面第一个加载完毕后执行的函数
        function onReady() {
            var grid = X(gridClientID);
            grid.addListener('viewready', function () {
                calcGridSummary(grid);
            });

            // 防止选中合计行
            grid.getSelectionModel().addListener('beforerowselect', function (sm, rowIndex, keepExisting, record) {
                if (Ext.get(grid.getView().getRow(rowIndex)).hasClass('mygrid-row-summary')) {
                    return false;
                }
                return true;
            });
        }

        // 页面AJAX回发后执行的函数
        function onAjaxReady() {
            var grid = X(gridClientID);
            calcGridSummary(grid);
        }
    </script>
</body>
</html>

